//
//  UIBarButtonItem+WWBarButton.m
//  微博OC
//
//  Created by 张湾湾 on 16/7/20.
//  Copyright © 2016年 张湾湾. All rights reserved.
//

#import "UIBarButtonItem+WWBarButton.h"
#import "WWButton.h"

@interface UITabBarItem(WWBarButton)

@end

@implementation UIBarButtonItem (WWBarButton)

+ (UIBarButtonItem *)barButtonItemWithTitle:(NSString *)title image:(NSString *)image target:(id)target action:(SEL)sel{

    WWButton * btn = [[WWButton alloc]init];
    
    //是title
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    //是imageview
    if (image) {
        [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    }

    //点击事件
    [btn addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    
    [btn sizeToFit];
    
    return  [[UIBarButtonItem alloc]initWithCustomView:btn];
    
}


+ (UIBarButtonItem *)barButtonItemWithImageName:(NSString *)imageName target:(id)target action:(SEL)sel{
    
    UIButton * btn = [[UIButton alloc]init];
    btn.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
    
    //是imageview
    if (imageName) {
        [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    }
    
    //点击事件
    [btn addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    
    [btn sizeToFit];
    
    return  [[UIBarButtonItem alloc]initWithCustomView:btn];
    
}



@end
